<template>
	<view class="main-content">
		<rewaredComp :item="item" :rewardType="item.askrentId?1:2" @tgMeth="rewardId=>$emit('tgMeth',rewardId)" @updateItem ="(k,v)=>$emit('updateItem', k, v)" />
		<view class="main-tittle acea-row row-between">
<!-- 			<view class="tittle-left" style="width: 35%;">
				<text v-if="item.storeCategoryName">{{item.storeCategoryName}}<text
						style="margin: 0 10rpx  ;">|</text></text>{{ item.title }}
			</view> -->
			
		<!-- 	<view class="acea-row row-middle row-between ">
				<template v-if="item.isReward==2">
					<text class='tittle-right acea-row row-center v' @click="publish " style="margin-right: 3px;">发布悬赏</text>
				</template>
				<template v-else>
					<text class='tittle-right acea-row row-center v' @click="publish" style="margin-right: 3px;">修改悬赏</text>
					<template v-if="item.rewardStatus == 1">
						<text class='tittle-right acea-row row-center v' @click="setReward(0)" style="margin-right: 3px;">打开悬赏</text>
						<text class='tittle-right acea-row row-center v' v-if="item.trusteeship !='1'" @click="deleteReward" style="margin-right: 3px;">删除悬赏</text>
					</template>
					<template v-else>
						<text class='tittle-right acea-row row-center v' @click="setReward(1)" style="margin-right: 3px;">关闭悬赏</text>
					</template>
				</template>
				<text class="tittle-right acea-row row-center v" @click="$emit('tgMeth',item.rewardId)"
					v-if="item.isReward == '1' &&item.trusteeship !='1'">
					立即托管
				</text>

			</view> -->
		</view>
		<view class="mian-center acea-row row-between"
			@click="toPage('/pages/details/askRent/askRent?mind=1&'+ (item.buystoreId ? 'buystoreId=' : 'askrentId=' ) + (item.buystoreId ? item.buystoreId : item.askrentId )+'&storeCategory='+item.storeCategory)">
			<view class="center-left" v-if="item.askrentId">
				<p>面积：{{ item.area || 0 }}㎡</p>
				<p>租金：{{ item.rent || 0 }}元</p>
				<p>计划经营：{{item.categoryName || ''}}</p>
				<!-- <p>期望经营：20-50</p> -->
			</view>
			<view class="center-left" v-else>
				<p>面积：{{ item.area || 0 }}㎡</p>
				<p>投资金额：{{ item.money || 0 }}万</p>
				<p>投资回报率：{{ item.rate?item.rate+'%':'暂无' }}</p>
				<p>期望区域：{{item.hopeAreaName || ''}}</p>
				<!-- <p>期望经营：20-50</p> -->
			</view>
			<view class="center-right" style="min-width: 80rpx;">
				{{ item.isUp == 0 ? '上线' : ( item.isUp == 1 ? '下线' : '成交') }}
			</view>
		</view>
		<view class="item-bottom">
			<p>已为您匹配到{{item.matchingNum?item.matchingNum:0}}人·浏览 {{item.view?item.view:0}} ·咨询
				{{item.communication?item.communication:0}}
			</p>
		</view>
		<view class="main-bottom acea-row row-between">

			<view class="bottom-btn  acea-row row-center"
				@click="$emit('to-topping',item.buystoreId?item.buystoreId:item.askrentId,item.buystoreId?'qg':'qz',item.storeCategory,item.status)">
				{{item.sort == '1'?'已置顶':'置顶'}}
			</view>
			<view class="bottom-btn  acea-row row-center">
				群发
			</view>
			<view @click="$emit('toVip',item)"
				:class="item.isVip== 1?'vip bottom-btn  acea-row row-center':'bottom-btn  acea-row row-center'">
				{{item.isVip == '1'?'VIP信息':'VIP'}}
			</view>
			<view class="bottom-btn acea-row row-center" @click="$emit('visitor',item)">
				访客
			</view>
			<view class="bottom-btn acea-row row-center" @click="$emit('jumpPage',item)">
				编辑
			</view>
			<view class="bottom-btn acea-row row-center" @click="$emit('setMeth',item)">
				设置
			</view>
		</view>
		<!-- 		<u-modal :show="show" @confirm="Topping" @close="show = false" ref="uModal" :closeOnClickOverlay="true">
			<view style="width: 100%;">
				<u--input
				    placeholder="请输入置顶时间(小时)"
				    border="surround"
				    v-model="setTime"
				  ></u--input>
			</view>
		</u-modal> -->
	</view>
</template>

<script>
	
	import {
		toPage
	} from '@/filters/commFilter.js'
	import {
		closeReward,
		deleteReward
	} from '@/api/api.js'
	import {
		zdInformation
	} from '@/api/api.js'
	import {
		GroupDetailApi
	} from '@/api/subletOfShop.js'
	import rewaredComp from './publishReward/index.vue'
	export default {
		components:{
			rewaredComp
		},
		props: ['item'],
		data() {
			return {
				show: false,
				setTime: '',

			}
		},
		mounted() {
			console.log(this.item)

		},
		methods: {
			toPage,
			publish() {
				if (this.item.isReward == 1) {
					return;
				}
				let item = JSON.stringify(this.item)
				uni.navigateTo({
					url: '/pages/releases/offeraRreward/offeraRreward?item=' + item
				})
			},
			// toDetail(){
			// 	uni.navigateTo({
			// 		url:'/pages/releases/subletOfShop/subletOfShop?categoryOn=' + categoryOn + '&typeOn=' + typeOn + '&id='+ this.item.id
			// 	})
			// },
			jumpPage() {
				console.log(this.item)
				let categoryOn = null;
				let typeOn = this.item.status == '0' ? 0 : (this.item.status == '1' ? 3 : 1);
				let enums = {
					883: 0,
					884: 1,
					1014: 2,
					911: 3,
					885: 4,
					912: 5,
					913: 6,
				}
				categoryOn = enums[this.item.storeCategory];
				toPage('/pages/releases/subletOfShop/subletOfShop?categoryOn=' + categoryOn + '&typeOn=' + typeOn +
					'&id=' + this.item.id)
			},
			setReward(st){
				let that = this;
				uni.showModal({
					title: '提示',
					content: '是否'+(st==1?'关闭':'打开')+'当前悬赏',
					success: function (res) {
						if (res.confirm) {
							closeReward({
								id: that.item.rewardId,
								status: st
							}).then(res=>{
								// that.item. 'rewardStatus' = st;
								that.$emit("updateItem",'rewardStatus',st)
								that.$util.Tips({
									title: (st==1?'关闭':'打开')+'悬赏成功'
								})
								// that.item.rewardStatus = st;
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
				
			},
			deleteReward(){
				let that = this;
				uni.showModal({
					title: '提示',
					content: '是否删除当前悬赏',
					success: function (res) {
						if (res.confirm) {
							console.log("that.item.rewardId",that.item.rewardId)
							deleteReward(that.item.rewardId).then(res=>{
								// that.item. 'rewardStatus' = st;
								that.$emit("updateItem",'isReward',2)
								that.$util.Tips({
									title: '删除悬赏成功'
								})
								// that.item.rewardStatus = st;
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			Topping() {
				let item = this.item
				let that = this;
				if (item.sort == 1) {
					return;
				}
				if (!this.setTime) {
					return this.$util.Tips({
						title: '请输入置顶时间'
					})
				}
				uni.showModal({
					title: '提示',
					content: '是否要置顶',
					success: function(res) {
						that.show = false;
						if (res.confirm) {
							let type = ''
							let params = {
								sort: 1,
								setTime: that.setTime
							}
							if (item.askrentId) {
								params['askrentId'] = item.askrentId
								type = 'qz'
							} else if (item.buystoreId) {
								params['buystoreId'] = item.buystoreId
								type = 'qg'
							}
							zdInformation(type, params).then(res => {
								if (res.code == 200) {
									that.$emit('opear', res.message)
								}
							})
						}
					}
				});

			}
		},
	}
</script>

<style lang="scss">
	.main-content {
		padding: 0 30rpx;
		border-radius: 20rpx;
		background: rgba(255, 255, 255, 1);
		margin: 0 28rpx 28rpx 28rpx;

		.main-tittle {
			border-bottom: 2rpx solid rgba(238, 238, 238, 1);
			padding: 24rpx 0 18rpx 0;

			.tittle-left {
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				font-size: 30rpx;
				width: 80%;
				font-weight: 400;
				color: rgba(56, 56, 56, 1);
			}

			.tittle-right {
				// width: 100%;
				line-height: 44rpx;
				height: 44rpx;
				border-radius: 10rpx;
				background: rgba(238, 33, 45, 1);
				font-size: 24rpx;
				color: rgba(255, 255, 255, 1);
			}
		}

		.mian-center {
			padding: 14rpx 0 20rpx 0;
			border-bottom: 2rpx solid rgba(238, 238, 238, 1);

			.center-left {
				p {
					font-size: 24rpx;
					line-height: 40rpx;
					color: rgba(128, 128, 128, 1);
				}
			}

			.center-right {
				font-size: 24rpx;
				// color: rgba(238, 33, 45, 1);
			}
		}

		.main-bottom {
			margin-top: 28rpx;

			.bottom-btn {
				width: 90rpx;
				font-size: 24rpx;
				line-height: 40rpx;
				color: rgba(128, 128, 128, 1);
				border-radius: 4rpx;
				border: 2rpx solid rgba(229, 229, 229, 1);
				margin-bottom: 32rpx;
			}
		}
	}

	.rt {
		margin-left: 20rpx;
	}

	.v {
		// display: flex;
		margin-left: 10rpx;
		padding: 1rpx 10rpx;
	}

	.vip {
		border: 1px solid red !important;
		color: red !important;
	}

	.item-bottom {
		p {
			margin-top: 20rpx;
			font-size: 22rpx;
			font-weight: 400;
			line-height: 40rpx;
			color: rgba(166, 166, 166, 1);
		}
	}
</style>